<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
<form:form commandName="SysDeptRoomFilter" cssClass="form-horizontal" role="form">
	<div class="form-group">
		<label class="col-sm-2 control-label no-padding-right" for="name-filter">科室名称</label>
		<div class="col-sm-4">
			<input type="text" name="roomName" id="name-filter" placeholder="请输入科室名称" class="form-control"
				   value="${SysDeptRoomFilter.roomName}">
		</div>
		<%--<label class="col-sm-2 control-label no-padding-right" for="name-filter">科室编码roomId</label>--%>
		<div class="col-sm-4" style="display: none;">
			<input type="text" name="roomId"  placeholder="" class="form-control" id="theRoomId"
				   value="${roomId}">
		</div>

	</div>

	<div class="form-group">
		<%--<label class="col-sm-2 control-label no-padding-right" for=orderBy>排序</label>
		<div class="col-sm-4">
			<input type="number" name="orderBy" id="orderBy" placeholder="请输入排序" value="${SysDeptRoomFilter.orderBy}"
				   class="form-control">
		</div>

		<label class="col-sm-1 control-label no-padding-right" for="state">状态</label>
		<div class="col-sm-4">
			<form:select path="state" items="${redis:getDictList('DeptState',false)}" itemLabel="name" itemValue="basId"
						 cssClass="form-control required"></form:select>
		</div>--%>
	</div>


	<div class="form-group">

		<label class="col-sm-2 control-label no-padding-right">选择科室人员</label>
		<div class="col-sm-4" id="checkboxs" style="padding-top: 5px">
			<input id="allcheck" type="checkbox" onclick="checkAll(this)" style="border-bottom: 1px solid slategray" />
			<label for="allcheck">全选</label>
			<br/>
		</div>

	</div>

	<%--<input type="text" id="sysId" value="${SysDeptRoomFilter.sysId}" hidden>--%>
	<form:hidden path="sysId"/>
</form:form>
<script type="text/javascript">
	$.ajax({
		type: "GET",
		url: "/sys/deptRoom/romuser?roomId="+ $("#theRoomId").val(),
		contentType: 'application/json;charset=utf-8',
		dataType: "json",
		success: function (data) {
			console.log(data)
			var html;
			for(let i=0;i<data.data.length;i++){
				var label =  document.createElement("label")
				label.setAttribute("for",data.data[i].userId)
				label.innerText = data.data[i].userName
				var input  = document.createElement("input")
				var br =  document.createElement("br")
				input.setAttribute("class","mycheckbox")
				input.id = data.data[i].userId
				input.type = "checkbox"
				input.name = "checkIds"
				input.value = data.data[i].userId
				if(data.data[i].checked == 1){
					input.checked = "checked"
				}
				// if(data.data[i].otherCheck == 1){
				// 	input.disabled = "disabled"
				// }
				var checkboxs = document.querySelector("#checkboxs")
				checkboxs.append(input)
				checkboxs.append(label)
				checkboxs.append(br)
			}
		}
	});
	function checkAll(data){
		if(data.checked == true){
			var checkboxs = document.querySelectorAll(".mycheckbox")
			for (let i = 0; i < checkboxs.length; i++) {
				checkboxs[i].checked = "checked"
			}
		}else{
			var checkboxs = document.querySelectorAll(".mycheckbox")
			for (let i = 0; i < checkboxs.length; i++) {
				checkboxs[i].checked = ""
			}
		}
	}
</script>
